<!DOCTYPE html>
<html>
<body>
<p>This test ensures WebKit merges text decorations in the typing style and the focused element's style property.</p>
<div id="test" contenteditable>hello world</div>
<pre><script>

if (window.testRunner)
    testRunner.dumpAsText();

function queryTextDecorations() {
    var result = '';
    if (document.queryCommandState('underline'))
        result += 'underline';
    if (document.queryCommandState('strikeThrough')) {
        if (result.length)
            result += ' ';
        result += 'strikeThrough';
    }
    return result;
}

function runTest(command, inlineStyle) {
    document.writeln('Test to set ' + command + ' by typing command and add ' + inlineStyle + ' as inline style:');
    var test = document.getElementById('test');
    test.style.textDecoration = null;
    window.getSelection().collapse(test, 0);
    document.execCommand(command, false, null);
    test.style.textDecoration = inlineStyle;
    if (queryTextDecorations() != 'underline strikeThrough')
        document.writeln('FAIL: got "' + queryTextDecorations() + '" but expected "underline strikeThrough"');
    else
        document.writeln('PASS');
    document.writeln();
}

runTest('strikeThrough', 'underline');
window.getSelection().collapse(test, 1);
runTest('underline', 'line-through');

</script></pre>
</body>
</html>
